//
//  DiskGesturePassword.m
//  newTestGit
//
//  Created by fangjs on 16/3/17.
//  Copyright © 2016年 Hongshi. All rights reserved.
//

#import "DiskGesturePassword.h"

@implementation DiskGesturePassword


+(instancetype)shareDiskGestruePassword {
    static DiskGesturePassword *diskGesturePassword = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{

        diskGesturePassword = [[DiskGesturePassword alloc] init];
        diskGesturePassword.userdefault = [NSUserDefaults standardUserDefaults];
    });
    return diskGesturePassword;
}


- (BOOL) isExistPassword:(NSString *) uid {
    return [[self.userdefault objectForKey:KEY_CURRENT_UID] isEqualToString:uid];
}

- (BOOL)diskContainsPassword {
    return [self.userdefault objectForKey:KEY_CURRENT_UID];
}

- (NSString *) getPassword:(NSString *) uid {
    return [self.userdefault objectForKey:uid];
}

- (void) setPassword:(NSString *) password withKey:(NSString *) uid {
    if (password == nil || [password isEqualToString:@""]) {
        [self removeUserPassword:uid];
        return;
    }
    [self.userdefault setObject:password forKey:uid];
    [self.userdefault synchronize];
}

- (void) removeUserPassword:(NSString *) uid {
//    [self.userdefault removeObjectForKey:uid];
    [self.userdefault removeObjectForKey:KEY_CURRENT_UID];
    [self.userdefault synchronize];
}












































@end
